home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / include / dlg_keys.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-16  |  3.6 KB  |  123 lines

  1. /*
  2.  *  $Id: dlg_keys.h,v 1.19 2005/12/07 01:43:14 tom Exp $
  3.  *
  4.  *  dlg_keys.h -- runtime binding support for dialog
  5.  *
  6.  *  Copyright 2005    Thomas E. Dickey
  7.  *
  8.  *  This program is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU Lesser General Public License as
  10.  *  published by the Free Software Foundation; either version 2.1 of the
  11.  *  License, or (at your option) any later version.
  12.  *
  13.  *  This program is distributed in the hope that it will be useful, but
  14.  *  WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *  Lesser General Public License for more details.
  17.  *
  18.  *  You should have received a copy of the GNU Lesser General Public
  19.  *  License along with this program; if not, write to
  20.  *    Free Software Foundation, Inc.
  21.  *    51 Franklin St., Fifth Floor
  22.  *    Boston, MA 02110, USA.
  23.  */
  24.  
  25. #ifndef DLG_KEYS_H_included
  26. #define DLG_KEYS_H_included 1
  27.  
  28. #include <dialog.h>
  29.  
  30. #ifdef DLG_USE_WIDE_CURSES
  31. #include <wctype.h>
  32. #define dlg_toupper(ch) towupper(ch)
  33. #define dlg_isupper(ch) iswupper(ch)
  34. #else
  35. #define dlg_toupper(ch) toupper(ch)
  36. #define dlg_isupper(ch) (isalpha(ch) && isupper(ch))
  37. #endif
  38.  
  39. typedef struct {
  40.     int is_function_key;
  41.     int    curses_key;
  42.     int dialog_key;
  43. } DLG_KEYS_BINDING;
  44.  
  45. #define DLG_KEYS_DATA(dialog, curses)  { curses >= KEY_MIN, curses, dialog }
  46.  
  47. #define END_KEYS_BINDING { -1, 0, 0 }
  48.  
  49. /*
  50.  * Define dialog's internal function-keys past the range used by curses.
  51.  */
  52. typedef enum {
  53.     DLGK_MIN = KEY_MAX + 1,
  54.     /* predefined buttons */
  55.     DLGK_OK,
  56.     DLGK_CANCEL,
  57.     DLGK_EXTRA,
  58.     DLGK_HELP,
  59.     DLGK_ESC,
  60.     /* moving from screen to screen (pages) */
  61.     DLGK_PAGE_FIRST,
  62.     DLGK_PAGE_LAST,
  63.     DLGK_PAGE_NEXT,
  64.     DLGK_PAGE_PREV,
  65.     /* moving within a list */
  66.     DLGK_ITEM_FIRST,
  67.     DLGK_ITEM_LAST,
  68.     DLGK_ITEM_NEXT,
  69.     DLGK_ITEM_PREV,
  70.     /* moving from field to field (or buttons) */
  71.     DLGK_FIELD_FIRST,
  72.     DLGK_FIELD_LAST,
  73.     DLGK_FIELD_NEXT,
  74.     DLGK_FIELD_PREV,
  75.     /* moving within a grid */
  76.     DLGK_GRID_UP,
  77.     DLGK_GRID_DOWN,
  78.     DLGK_GRID_LEFT,
  79.     DLGK_GRID_RIGHT,
  80.     /* delete */
  81.     DLGK_DELETE_LEFT,
  82.     DLGK_DELETE_RIGHT,
  83.     DLGK_DELETE_ALL,
  84.     /* special */
  85.     DLGK_ENTER,
  86.     DLGK_BEGIN,
  87.     DLGK_FINAL,
  88.     DLGK_SELECT
  89. } DLG_KEYS_ENUM;
  90.  
  91. #define is_DLGK_MOUSE(code)    ((code) >= M_EVENT)
  92. #define DLGK_MOUSE(code)    ((code) + M_EVENT)
  93.  
  94. #define ENTERKEY_BINDINGS \
  95.     DLG_KEYS_DATA( DLGK_ENTER,       '\n' ), \
  96.     DLG_KEYS_DATA( DLGK_ENTER,       '\r' ), \
  97.     DLG_KEYS_DATA( DLGK_ENTER,       KEY_ENTER )
  98.  
  99. /* ^U == 21 */
  100. #define INPUTSTR_BINDINGS \
  101.     DLG_KEYS_DATA( DLGK_BEGIN,       KEY_HOME ), \
  102.     DLG_KEYS_DATA( DLGK_DELETE_ALL,    21 ), \
  103.     DLG_KEYS_DATA( DLGK_DELETE_LEFT,   CHR_BACKSPACE ), \
  104.     DLG_KEYS_DATA( DLGK_DELETE_LEFT,   KEY_BACKSPACE ), \
  105.     DLG_KEYS_DATA( DLGK_DELETE_RIGHT,  CHR_DELETE ), \
  106.     DLG_KEYS_DATA( DLGK_DELETE_RIGHT,  KEY_DC ), \
  107.     DLG_KEYS_DATA( DLGK_FINAL,       KEY_END ), \
  108.     DLG_KEYS_DATA( DLGK_GRID_LEFT,       KEY_LEFT ), \
  109.     DLG_KEYS_DATA( DLGK_GRID_RIGHT,       KEY_RIGHT )
  110.  
  111. extern int dlg_lookup_key(WINDOW * /*win*/, int /*curses_key*/, int * /*dialog_key*/);
  112. extern int dlg_result_key(int /*dialog_key*/, int /*fkey*/, int * /*resultp*/);
  113. extern void dlg_register_buttons(WINDOW * /*win*/, const char * /*name*/, const char ** /*buttons*/);
  114. extern void dlg_register_window(WINDOW * /*win*/, const char * /*name*/, DLG_KEYS_BINDING * /*binding*/);
  115. extern void dlg_unregister_window(WINDOW * /*win*/);
  116.  
  117. #ifdef DLG_HAVE_RC_FILE
  118. extern int dlg_parse_bindkey(char * /*params*/);
  119. extern void dlg_dump_keys(FILE * /*fp*/);
  120. #endif
  121.  
  122. #endif /* DLG_KEYS_H_included */
  123.